import 'package:flutter/material.dart';

main() {
  runApp(FullAppMa());
}

//-------------------------- fullwidget1 -------------------------------

// class FullAppMaterial extends StatelessWidget {
//   const FullAppMaterial({Key? key}) : super(key: key);
//
//   @override
//   Widget build(BuildContext context) {
//     return MaterialApp(
//       theme: ThemeData(primaryColor: Colors.lightBlue),
//       home: Scaffold(
//         appBar: AppBar(title: Text('this is an bar'),),
//         body: FullApp(),
//       ),
//     );
//   }
// }
//
// //快捷键stless创建statelesswidget
// //快捷键stful
// class FullApp extends StatefulWidget {
//   const FullApp({Key? key}) : super(key: key);
//
//   @override
//   _FullAppState createState() => _FullAppState();
// }
//
// class _FullAppState extends State<FullApp> {
//
//   int _year=1998;
//
//   @override
//   Widget build(BuildContext context) {
//     return Column(
//
//       children: [
//
//         Chip(label: Text('你好呀,$_year')),
//         ElevatedButton(onPressed: (){
//           setState(() {
//             _year++;
//           });
//
//         }, child: Text('点击'))
//       ],
//     );
//   }
// }

//-------------------------- fullwidget2 -------------------------------

class FullAppMa extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(primaryColor: Colors.lightBlue),
      home: Scaffold(
        appBar: AppBar(
          title: Text('fullwiget2'),
        ),
        body: FullAppMaterial(),
      ),
    );
  }
}

class FullAppMaterial extends StatefulWidget {
  FullAppMaterial({Key? key}) : super(key: key);

  @override
  _FullAppMaterialState createState() => _FullAppMaterialState();
}

class _FullAppMaterialState extends State<FullAppMaterial> {
  List<Widget> list = [
    ListTile(title: Text('数据一')),
    ListTile(title: Text('数据二'))
  ];

  void _addList() {
    list.add(ListTile(
      title: Text('数据一'),
    ));
    list.add(ListTile(
      title: Text('数据二'),
    ));
  }

  List<Widget> _addWidget() {

    return list.map((e) {
      return e;
    }).toList();

  }


  @override
  Widget build(BuildContext context) {
    return ListView(
      children: [
        Column(
          children: list.map((e) {
            return e;
          }).toList(),
        ),
        ElevatedButton(
            onPressed: () {
              print('====== ss ======');
              setState(() {
                _addList();
              });
            },
            child: Text('按钮')),
      ],
    );
  }
}
